package Sort;

import java.util.Arrays;

/**
 * @author zhangmin
 * @create 2022-04-18 10:59
 */
public class InstertionSort<T extends Comparable<T>> extends Sort<T> {
    @Override
    public void sort(T[] nums) {
        int n=nums.length;
        for (int i = 1; i < n; i++) {
            for (int j = i; j >0&&less(nums[j],nums[j-1]); j--) {
                swap(nums,j,j-1);
            }
        }
    }
    public static void main(String[] args) {
        Integer[] nums={3,5,6,4,1,2};
        InstertionSort<Integer> integerInstertionSort=new InstertionSort<Integer>();
        integerInstertionSort.sort(nums);
        System.out.println(Arrays.toString(nums));
    }
}
